import Vue from 'vue'
import Vuex from 'vuex'
import createVuexAlong from "vuex-along";

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    // makeorder中的数量
    sum: 0,
    // mekeorder中的总价
    total: 0,
    // 购物袋shopbag
    orderArray: [],
    //编辑地址对象
    addressInfo: {},
    //新增地址对象
    addressAdd: {},
    //地址列表数组
    list: [],
    //我的订单商品
    // myOrderArr: [],
    //我的背景
    pictureUrl: '',
    //我的头像
    myheadpic:'',
    //我的昵称
    nickName:'',

  },
  mutations: {
    
    //购物袋shopbag 
    getSum(state,payload) {
      // 
      state.sum=payload.sum;
      state.total=payload.total;
      state.orderArray=payload.orderArray;
    },
    //编辑的地址保存
    getAddress(state,payload) {
      state.addressInfo=payload;
    },
    //新增地址保存
    setAddress(state,payload) {
      state.addressAdd=payload;
    },
    //地址列表数据保存
    setList(state,payload) {
      // 
      state.list=payload;
    },
    //我的订单数据
    // setMyOrderArr(state,payload) {
    //   state.myOrderArr=payload;
    // },
    //personal组件 我的背景图片
    setMyPicture(state,payload) {
      // 
      state.pictureUrl=payload;
    },
    //我的头像
    setMyHead(state,payload) {
      state.myheadpic=payload.myheadpic;
      state.nickName=payload.nickName;
    }

  },
  actions: {
  },
  modules: {
  },
  // 让我的地址列表数据切换组件时不被销毁
  plugins: [
    createVuexAlong()
  ]
})
